var express = require("express");
var router = express.Router();
var fs = require("fs");
const path = require("path");

router.post("/api/v1/deleimg", function(req, res, next) {
  let deleImgArr = req.body.deleImgArr;
  console.log(deleImgArr);
  if (deleImgArr.length != 0) {
    deleImgArr.forEach(item => {
      console.log(item);
      fs.unlink(path.join(__dirname, "../public/images/" +req.body.upload+'/'+item), function(
        error
      ) {
        if (error) {
          console.log(error);
          return false;
        }
        console.log("删除文件成功");
      });
    });
  }
  res.json({
    code: 200
  });
});
// 导出模块（在 app.js 中引入）
module.exports = router;
